#ifndef BYTESTREAM_H
#define BYTESTREAM_H


class ByteStream
{
private:
	struct ByteSegment
	{
		struct ByteSegment *next;
		struct ByteSegment *previous;
		unsigned int size;
	};

	typedef struct ByteSegment ByteSegment;

public:
	ByteStream();
	~ByteStream();

	virtual void Write(const void *data, unsigned int size);
	virtual unsigned int Read(void *data, unsigned int size);
	virtual void WriteRaw(const void *data, unsigned int size);
	virtual unsigned int ReadRaw(void *data, unsigned int size);

	virtual void WriteToFile(const char *filename);
	virtual void ReadFromFile(const char* filename);

	bool Eob() const;


protected:
	virtual void Clear();

private:
	ByteStream(const ByteStream& rhs); // copy constructor not implemented yet
	
	void AddSegment(ByteSegment *segment);
	void RemoveFirstSegment();

	ByteSegment *segmentlist;
	unsigned int segmentpos;
};

#endif //BYTESTREAM_H
